import { createSlice } from "@reduxjs/toolkit"

const countSlice = createSlice({
    name:"counter",
    initialState:{
        count:1
    },
    reducers:{
        sub:(state)=>{
            state.count ++
        },
        dec:(state)=>{
            state.count --
        },
        setCount:(state,action)=>{
            state.count = action.payload
        }
    }
})

export const {sub,dec,setCount} = countSlice.actions



export default countSlice.reducer